package com.baway.common.dialog

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.Window
import android.widget.TextView
import com.baway.common.R

/**
 * Author: Jason Zhang
 * Date: 2025/8/30
 * Desc: 加载提示
 */
class LoadingDialog(context: Context, private val loadingText: String = "加载中...") : Dialog(context) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //隐藏状态栏
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        setContentView(R.layout.loading_dialog_layout)

        //设置弹窗样式
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        //边缘是否可以取消
        setCanceledOnTouchOutside(false)

        //设置提示文本
        findViewById<TextView>(R.id.tv_loading)?.text = loadingText
    }

    /**
     * 提供单独设置加载文本
     */
    fun setLoadingText(loadingText: String) {
        findViewById<TextView>(R.id.tv_loading)?.text = loadingText
    }

}